package com.demo.java.spi.test;

import com.demo.java.spi.dubbo.Robbot;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * dubbo SPI扩展，可以根据名称获取service, 避免了JDK中classpath加载顺序的问题
 */
public class DobboServiceLoad {
    public static void main(String[] args) {
        ExtensionLoader<Robbot> extensionLoader = ExtensionLoader.getExtensionLoader(Robbot.class);

        Robbot defaultExtension = extensionLoader.getDefaultExtension();
        defaultExtension.sayHello();

        Robbot bumblebee = extensionLoader.getExtension("bumblebee");
        bumblebee.sayHello();

        Robbot optimusPrime = extensionLoader.getExtension("optimusPrime");
        optimusPrime.sayHello();
    }
}
